package handler;

import mysql.Conn;

import java.sql.SQLException;

//TODO：安全性封装Conn 更新数据库中数据状态
public class Refresh {
    public static Conn conn = new Conn();
    public static void refresh_state1(String au) throws SQLException {
        conn.getConn();
        Boolean ok = conn.updatestate1(au);
        if (ok){
            System.out.println("更新state成功");
        }
        conn.close();
    }
    public static void refresh_state2(String au) throws SQLException {
        conn.getConn();
        Boolean ok = conn.updatestate2(au);
        if (ok){
            System.out.println("更新state成功");
        }
        conn.close();
    }
    public static void refresh_u_a(String au,String username) throws SQLException {
        conn.getConn();
        Boolean ok =conn.Insertusercode(username,au);
        if (ok){
            System.out.println("添加user_code成功");
        }
        conn.close();
    }

    public static int checkstate(String au) throws SQLException {
        conn.getConn();
        int i = conn.checkstate(au);
        if (i == 0 ){
            return 0;
        }else if (i == 1){
            return 1;
        }else return -1;

    }


}
